<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            min-height: 100vh;
            /*background: rgb(20, 172, 231);*/
            background: linear-gradient(#141e30, #243b55);
            display: flex;
            justify-content: center;
            align-items: center;
            transition: 0.5s;
        }

        body.active {
            background: #f43648;
        }

        .container {
            position: relative;
            width: 800px;
            height: 500px;
            /* background: red; */
            margin: 20px;
        }

        .blueBg {
            display: flex;
            justify-content: center;
            align-items: center;
            position: absolute;
            top: 40px;
            width: 100%;
            height: 420px;
            background: rgba(255, 255, 255, 0.2);
            box-shadow: 0 5px 45px rgba(0, 0, 0, 0.15);
        }

        .blueBg .box {
            position: relative;
            width: 50%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        .blueBg .box h2 {
            color: #fff;
            font-size: 1.2em;
            font-weight: 500;
            margin-bottom: 10px;
        }

        .blueBg .box button {
            cursor: pointer;
            padding: 10px 20px;
            background: #fff;
            color: #333;
            font-size: 16px;
            font-weight: 500;
            border: none;
        }

        .formBx {
            position: absolute;
            top: 0;
            left: 0;
            width: 50%;
            height: 100%;
            /*background: rgba(0, 0, 0, 0.2);*/
            z-index: 999;
            display: flex;
            justify-content: center;
            align-items: center;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
            transition: 0.5s ease-in-out;
            overflow: hidden;
            background-color: rgba(133, 85, 85, 0.99);
            /*background-color: rgb(0, 0, 0);*/

        }

        .formBx.active {
            left: 50%;
        }

        .formBx .form {
            position: absolute;
            left: 0;
            width: 100%;
            padding: 50px;
            transition: 0.5s;
        }

        .formBx .form form {
            display: flex;
            width: 100%;
            flex-direction: column;
        }

        .formBx .signinForm {
            transition-delay: 0.25s;
        }

        .formBx.active .signinForm {
            left: -100%;
            transition-delay: 0s;
        }

        .formBx .signupForm {
            left: -100%;
            transition-delay: 0.25s;
        }

        .formBx.active .signupForm {
            left: 0;
            transition-delay: 0s;
        }

        .formBx .form h3 {
            font-size: 1.5em;
            /*color: #333;*/
            /*margin: 20px;*/
            font-weight: 500;
        }

        /*.formBx .signupForm form input {*/
        /*    !*width: 100%;*!*/
        /*    !*margin-bottom: 20px;//下边距*!*/
        /*    !*padding: 10px;*!*/
        /*    !*outline: none;*!*/
        /*    !*font-size: 16px;*!*/
        /*    !*border: 1px solid #333;*!*/
        /*     清除input框自带的边框和轮廓*/
        /*    outline: none;*/
        /*    border: none;*/
        /*    width: 100%;*/
        /*    padding: 10px 0;*/
        /*    margin-bottom: 30px;*/
        /*    color: #fff;*/
        /*    font-size: 16px;*/
        /*    border-bottom: 1px solid #fff;*/
        /*    !* 背景颜色为透明色 *!*/
        /*    background-color: transparent;*/
        /*}*/

        /*.formBx .signupForm form label*/
        /*!*form input[type="submit"] *!*/
        /*{*/
        /*    !*background: #03a9f4;*!*/
        /*    !*border: none;*!*/
        /*    !*color: #fff;*!*/
        /*    !*max-width: 100px;*!*/
        /*    !*cursor: pointer;*!*/
        /*    position: absolute;*/
        /*    top: 0;*/
        /*    left: 0;*/
        /*    padding: 10px 0;*/
        /*    color: #FFFFFF;*/
        /*    !* 这个属性的默认值是auto 默认是这个元素可以被点击 但是如果我们写了none 就是这个元素不能被点击 , 就好像它可见但是不能用 可望而不可即 *!*/
        /*    !* 这个就是两者的区别 *!*/
        /*    pointer-events: none;*/
        /*    !* 加个过渡 *!*/
        /*    transition: all 0.5s;*/
        /*}*/
        /*.formBx .signupForm input:focus + label,*/
        /*.formBx .signupForm input:valid + label {*/
        /*    top: -20px;*/
        /*    color: #03e9f4;*/
        /*    !*color: #FFFFFF;*!*/
        /*    font-size: 12px;*/
        /*}*/

        .formBx.active .signupForm input[type="submit"] {
            background: #f43648;
        }

        /*.formBx .form form .forget {*/
        /*    color: #333;*/
        /*    !* text-decoration: none; *!*/
        /*}*/

        .form .login_box {
            /* 相对定位 */
            position: relative;
            width: 100%;
        }

        .form .login_box input {
            /* 清除input框自带的边框和轮廓 */
            outline: none;
            border: none;
            width: 100%;
            padding: 10px 0;
            margin-bottom: 30px;
            color: #fff;
            font-size: 16px;
            border-bottom: 1px solid #fff;
            /* 背景颜色为透明色 */
            background-color: transparent;
        }

        .form .login_box label {
            position: absolute;
            top: 0;
            left: 0;
            padding: 10px 0;
            color: #fff;
            /* 这个属性的默认值是auto 默认是这个元素可以被点击 但是如果我们写了none
             就是这个元素不能被点击 , 就好像它可见但是不能用 可望而不可即 */
            /* 这个就是两者的区别 */
            pointer-events: none;
            /* 加个过渡 */
            transition: all 0.5s;
        }

        /* :focus 选择器是当input获得焦点是触发的样式 + 是相邻兄弟选择器
        去找与input相邻的兄弟label */
        /* :valid 选择器是判断input框的内容是否合法,如果合法会执行下面的属性代码,
        不合法就不会执行,我们刚开始写布局的时候给input框写了required 我们删掉看对比
        当没有required的话input框的值就会被认为一直合法,所以一直都是下方的样式 ,
        但是密码不会,密码框内的值为空,那么这句话局不合法,required不能为空
        当我们给密码框写点东西的时候才会执行以下代码*/
        .form .login_box input:focus + label,
        .form .login_box input:valid + label {
            top: -20px;
            color: #03e9f4;
            font-size: 12px;
        }

        .formBx .form form a {
            width: 50%;
            margin: 0 auto;
            overflow: hidden;
            position: relative;
            padding: 10px 20px;
            color: #03e9f4;
            /* 取消a标签原有的下划线 */
            text-decoration: none;
            /* 同样加个过渡 */
            transition: all 0.5s;
        }

        .formBx .form form .register:hover {
            color: #fff;
            border-radius: 5px;
            background-color: #03e9f4;
            box-shadow: 0 0 5px #03e9f4, 0 0 25px #03e9f4, 0 0 50px #03e9f4,
            0 0 100px #03e9f4;
        }

        .formBx .form form .register span {
            position: absolute;
        }

        .formBx .form form .register span:first-child {
            top: 0;
            left: -100%;
            width: 100%;
            height: 2px;
            /* to right 就是往右边 下面的同理 */
            background: linear-gradient(to right, transparent, #03e9f4);
            /* 动画 名称 时长 linear是匀速运动 infinite是无限次运动 */
            animation: move1 1s linear infinite;
        }

        .formBx .form form .register span:nth-child(2) {
            right: 0;
            top: -100%;
            width: 2px;
            height: 100%;
            background: linear-gradient(transparent, #03e9f4);
            /* 这里多了个0.25s其实是延迟时间 */
            animation: move2 1s linear 0.25s infinite;
        }

        .formBx .form form .register span:nth-child(3) {
            right: -100%;
            bottom: 0;
            width: 100%;
            height: 2px;
            background: linear-gradient(to left, transparent, #03e9f4);
            animation: move3 1s linear 0.5s infinite;
        }

        .formBx .form form .register span:last-child {
            left: 0;
            bottom: -100%;
            width: 2px;
            height: 100%;
            background: linear-gradient(#03e9f4, transparent);
            animation: move4 1s linear 0.75s infinite;
        }
        @keyframes move1 {
            0% {
                left: -100%;
            }
            50%,
            100% {
                left: 100%;
            }
        }
        @keyframes move2 {
            0% {
                top: -100%;
            }
            50%,
            100% {
                top: 100%;
            }
        }
        @keyframes move3 {
            0% {
                right: -100%;
            }
            50%,
            100% {
                right: 100%;
            }
        }
        @keyframes move4 {
            0% {
                bottom: -100%;
            }
            50%,
            100% {
                bottom: 100%;
            }
        }

        @media (max-width: 991px) {
            .container {
                max-width: 400px;
                height: 650px;
                display: flex;
                justify-content: center;
                align-items: center;
            }

            .container .blueBg {
                top: 0;
                height: 100%;
            }

            .formBx {
                width: 100%;
                height: 500px;
                top: 0;
                box-shadow: none;
            }

            .blueBg .box {
                position: absolute;
                width: 100%;
                height: 150px;
                bottom: 0;
            }

            .box.signin {
                top: 0;
            }

            .formBx.active {
                left: 0;
                top: 150px;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <div class="blueBg">
        <div class="box signin">
            <h2>已经有一个账号?</h2>
            <button class="signinBtn">登录</button>
        </div>
        <div class="box signup">
            <h2>没有账号?</h2>
            <button class="signupBtn">注册</button>
        </div>
    </div>
    <div class="formBx">
        <div class="form signinForm">
            <form action="">
                <h3 style="color:#ffffff; text-align: center">登录</h3>
                <div class="login_box">
                    <!-- required就是不能为空 必须在css效果中有很大的作用 -->
                    <!-- 可以简写为required -->
                    <input type="text" required><label>用户名</label>
                </div>
                <div class="login_box">
                    <input type="password" required="required"><label>密码</label>
                </div>

                <a href="javascript:void(0)" class="register" style="text-align: center">
                    登录
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                </a>
                <a href="javascript:void(0)" class="forget" style="text-align: center">
                    忘记密码
                </a>
            </form>
        </div>
        <div class="form signupForm">
            <form action="">
                <h3 style="color:#ffffff; text-align: center">注册</h3>
                <div class="login_box">
                <input type="text" required><label>用户名</label>
                </div>
                <div class="login_box">
                <input type="text" required ><label>电子邮箱</label>
                </div>
                <div class="login_box">
                <input type="password" required><label>密码</label>
                </div>
                <div class="login_box">
                <input type="password"  required="required"><label>确认密码</label>
                </div>

                <a href="javascript:void(0)" class="register" style="text-align: center">
                    注册
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                </a>
                <!--<input type="submit" value="注册">-->
            </form>
        </div>

    </div>
</div>
<script>
    const signinBtn = document.querySelector('.signinBtn');
    const signupBtn = document.querySelector('.signupBtn');
    const formBx = document.querySelector('.formBx');
    const body = document.querySelector('body');

    signupBtn.onclick = function () {
        formBx.classList.add('active');
        body.classList.add('active');
    }
    signinBtn.onclick = function () {
        formBx.classList.remove('active');
        body.classList.remove('active');
    }
</script>
</body>
</html>